import type { RouteRecordRaw } from 'vue-router'
import { Layout } from '../constant'
import IconMenuExample from '~icons/local/menu-example-color'

// 通用配置
const common: RouteRecordRaw = {
  path: 'common',
  meta: {
    title: '通用配置',
    group: true,
  },
  children: [
    {
      path: 'dict',
      name: 'Dict',
      component: () => import('@/views/develop/dict/index.vue'),
      meta: {
        title: '字典配置',
        code: 'system:dict:manage',
        icon: 'icon-bookmark',
      },
    },
    {
      path: 'config',
      name: 'Config',
      component: () => import('@/views/develop/config/index.vue'),
      meta: {
        title: '参数配置',
        code: 'system:config:manage',
        icon: 'icon-settings',
      },
    },
    {
      path: 'resource',
      name: 'Resource',
      component: () => import('@/views/develop/resource/index.vue'),
      meta: {
        title: '资源配置',
        code: 'system:resource:manage',
        icon: 'icon-settings',
      },
    },
  ],
}
// 存储配置
const storage: RouteRecordRaw = {
  path: 'storage',
  meta: {
    title: '系统存储',
    group: true,
  },
  children: [
    {
      path: 'file',
      name: 'File',
      component: () => import('@/views/develop/file/index.vue'),
      meta: {
        title: '文件管理',
        code: 'system:file:manage',
        icon: 'icon-file',
      },
    },
    {
      path: 'setting',
      name: 'Storage',
      component: () => import('@/views/develop/storage/index.vue'),
      meta: {
        title: '存储配置',
        code: 'system:storage:manage',
        icon: 'icon-storage',
      },
    },
  ],
}

// 任务调度
const schedule: RouteRecordRaw = {
  path: 'schedule',
  meta: {
    title: '任务调度',
    group: true,
  },
  children: [
    {
      path: 'job',
      name: 'Job',
      component: () => import('@/views/develop/job/index.vue'),
      meta: {
        title: '任务管理',
        code: 'system:schedule:manage',
        icon: 'icon-file',
      },
    },
    {
      path: 'log',
      name: 'Log',
      component: () => import('@/views/develop/job/log/index.vue'),
      meta: {
        title: '任务日志',
        code: 'system:schedule:manage',
        icon: 'icon-storage',
      },
    },
  ],
}

// 系统监控
const monitor: RouteRecordRaw = {
  path: 'monitor',
  meta: {
    title: '系统监控',
    group: true,
  },
  children: [
    {
      path: 'online-user',
      name: 'OnlineUser',
      component: () => import('@/views/develop/monitor/OnlineUser.vue'),
      meta: {
        title: '在线用户',
        code: 'system:online-user:manage',
        icon: 'icon-file',
      },
    },
    {
      path: 'log',
      name: 'SystemLog',
      component: () => import('@/views/develop/monitor/SystemLog.vue'),
      meta: {
        title: '系统日志',
        code: 'system:log:manage',
        icon: 'icon-file',
      },
    },
  ],
}

export default <RouteRecordRaw> {
  path: '/develop',
  name: 'develop',
  component: Layout,
  meta: {
    title: '开发维护',
    icon: shallowRef(IconMenuExample),
    sort: 11,
  },
  children: [
    common,
    storage,
    schedule,
    monitor,
    {
      path: 'generator',
      name: 'Generator',
      component: () => import('@/views/develop/generator/index.vue'),
      meta: {
        title: '代码生成',
        code: 'develop:generator:view',
        icon: 'icon-code',
      },
    },
    {
      path: 'api-doc',
      name: 'ApiDoc',
      component: () => import('@/views/develop/generator/index.vue'),
      meta: {
        title: '接口文档',
        code: 'develop:generator:view',
        icon: 'icon-code',
        link: 'http://api.bingxuewenhua.com/doc.html',
      },
    },
  ],
}
